package g_proxy.c_protection;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * Created by wug on 2016/7/5 0005.
 */
public class EquipmentHandler implements InvocationHandler {
    HeroService heroService;

    public EquipmentHandler(HeroService heroService) {
        this.heroService = heroService;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        if (method.getName().equals("equipment")) {
            return method.invoke(heroService, args);
        } else {
            System.out.println("装备代理无该权限！");
            return new IllegalAccessException();
        }
    }
}
